﻿<%@ WebHandler Language="C#" Class="JsonGetSectionsArticle" %>

using System;
using System.Collections;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using LitJson;
using System.Collections.Generic;
using System.Text;
using BusinessLogic.BusinessRules;
using BusinessLogic.ClassFactory;
using Model;
using System.Text;


public class JsonGetSectionsArticle : IHttpHandler
{
    public bool IsReusable
    {
        get { return true; }
    }
    public void ProcessRequest(HttpContext Context)
    {
        System.IO.Stream instream = Context.Request.InputStream;
        System.IO.BinaryReader br = new System.IO.BinaryReader(instream, System.Text.Encoding.UTF8);
        byte[] byt = br.ReadBytes((int)instream.Length);
        string sXml = System.Text.Encoding.UTF8.GetString(byt);

        // 解析通过Ajax传过来的xml文件
        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        xmlDoc.LoadXml(sXml);
        System.Xml.XmlElement xe = xmlDoc.DocumentElement;
       
        if (xe.SelectSingleNode("TopicTitle") != null)
        {
            using (SyntheticTableFactory objFactory = new SyntheticTableFactory())
            {
                SyntheticTable objSyntheticTable = objFactory.NewInstance();
                objSyntheticTable.DataItem.chvTitle = xe.SelectSingleNode("txtTitle").InnerXml;
                objSyntheticTable.DataItem.dtmAddTime = DateTime.Now;
                objSyntheticTable.DataItem.intTableType = 1;
                objSyntheticTable.DataItem.chvIpAddress = "";
                objSyntheticTable.DataItem.chvXmlContent = sXml;
                objSyntheticTable.Insert();
                Context.Response.Write("Success");
            }
           
        }
    }
}